package com.example.handler;

import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Component;

/**
 * @author ysb
 * @version V1.0
 * @Date 2024/11/12
 **/
@Component
public class ReceiverMessageHandler implements MessageHandler {
    @Override
    public void handleMessage(Message<?> message) throws MessagingException {
        Object payload = message.getPayload();
        System.out.println("接收到消息：" + payload);

        MessageHeaders headers = message.getHeaders();
        System.out.println("topicName:" + headers.get("mqtt_receivedTopic"));
        System.out.println("headers:" + headers);
    }
}
